//
//  CMessageFrame.m
//  wanzhaoIM
//
//  Created by wanzhao on 16/1/7.
//  Copyright © 2016年 liuyuantao. All rights reserved.
//

#import "CMessageFrame.h"
#import "NSString+Extension.h"


@implementation CMessageFrame
//bug 8514 fixed by lixu 
- (void)setMessage:(ChatMessageListCellData *)message
{
    _message = message;
    _iconFrame = CGRectMake(10.0f, 5.0f, 30.0f, 30.0f);
    _nameFrame = CGRectMake(CGRectGetMaxX(_iconFrame) + 10.0f, 5.0f, 100.0f , nameFont.lineHeight);
    
    _arrowFrame = CGRectMake(HARDWARE_SCREEN_WIDTH - 10.0f - timeFont.lineHeight, 5.0f, timeFont.lineHeight, timeFont.lineHeight);
    _timeFrame = CGRectMake(CGRectGetMaxX(_arrowFrame) - 5.0f - 100.0f, 5.0f, 100.0f, timeFont.lineHeight);
    CGSize contentSize =[message.content sizeWithFont:contentFont maxSize:CGSizeMake(HARDWARE_SCREEN_WIDTH - CGRectGetMaxX(_iconFrame) - 20.0f, contentFont.lineHeight)];
    _contentFrame = CGRectMake(CGRectGetMaxX(_iconFrame) + 10.0f, CGRectGetMaxY(_nameFrame) + 5.0f, contentSize.width, contentSize.height);
    if (CGRectGetMaxY(_contentFrame) + 5.0f > CGRectGetMaxY(_iconFrame)) {
        _cellHeight = CGRectGetMaxY(_contentFrame) + 5.0f;
    } else {
        _cellHeight = CGRectGetMaxY(_iconFrame) + 5.0f;
    }
    
    _lineframe = CGRectMake(CGRectGetMaxX(_iconFrame) + 10.0f, _cellHeight - 0.5f, HARDWARE_SCREEN_WIDTH - CGRectGetMaxX(_iconFrame) - 10.0f, 0.5f);
}

@end
